package com.hh.bss.mobile.controller;

import static com.hh.bss.util.extjs.JsonHelper.outJson;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

import com.hh.bss.base.BaseSpringController;
import com.hh.bss.common.page.Page;
import com.hh.bss.common.page.PageRequest;
import com.hh.bss.project.service.ContractJobCvRecomService;
import com.hh.bss.project.service.SearchProjectInterviewService;
import com.hh.bss.project.service.SearchProjectService;
import com.hh.bss.project.vo.query.ContactRecordQuery;
import com.hh.bss.project.vo.query.ContractJobCvRecomQuery;
import com.hh.bss.project.vo.query.SearchProjectInterviewQuery;
import com.hh.bss.talent.entity.Cv;
import com.hh.bss.talent.service.CvService;
import com.hh.bss.talent.vo.query.CvQuery;
import com.hh.bss.util.extjs.ExtJsPageHelper;
import com.hh.bss.util.extjs.ListRange;

@Controller
public class CvController extends BaseSpringController  {
	private CvService<Cv, Integer> cvService;
	private SearchProjectInterviewService searchProjectInterviewService;
	private ContractJobCvRecomService contractJobCvRecomService;
	private SearchProjectService searchProjectService;
	/** 通过spring自动注入 */
	public void setCvServiceImpl(CvService service) {
		this.cvService = service;
	}
	public void setSearchProjectInterviewServiceImpl(SearchProjectInterviewService service) {
		this.searchProjectInterviewService = service;
	}	
	public void setSearchProjectServiceImpl(SearchProjectService service) {
		this.searchProjectService = service;
	}
	public void setContractJobCvRecomServiceImpl(ContractJobCvRecomService service) {
		this.contractJobCvRecomService = service;
	}
	public ModelAndView exporthtml(HttpServletRequest req, HttpServletResponse res) {
		String cv_id = req.getParameter("id");
		logger.info(cv_id);
		//Map<String, Object> cvMap = cvService.getCvHtml(Integer.parseInt(cv_id));
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/test.jsp");
		//mv.setViewName("redirect:/talent/cv/extlist.do");
		
		//mv.addObject("cvMap", cvMap);
		// System.out.println(mv.toString());
		res.setCharacterEncoding("UTF-8");
		return mv;
	}
	public ModelAndView extlist(HttpServletRequest request, HttpServletResponse response, CvQuery cvQuery) throws IOException {
		Page page=cvService.findSimpleCvPage(cvQuery);
		//query.getPageSize(), query.getPageNumber()
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/cv/cvPage");		
		
		mv.addObject("pages", page);
		mv.addObject("query", cvQuery);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	public ModelAndView consultantInteviewList(HttpServletRequest request, HttpServletResponse response ,SearchProjectInterviewQuery searchProjectInterviewQuery) throws IOException {
		Page page = searchProjectInterviewService.findPage(searchProjectInterviewQuery);
		
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/cv/cvConsultantInteviewList");
		//System.out.println("数量："+page.getTotalCount());
		//System.out.println(page.getResult());
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	public ModelAndView recomList(HttpServletRequest request, HttpServletResponse response ,ContractJobCvRecomQuery contractJobCvRecomQuery) throws IOException {
		Page page = contractJobCvRecomService.findJobRecomCvPage(contractJobCvRecomQuery);
		
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/cv/cvRecomList");
		
		
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	public ModelAndView contactRecordList(HttpServletRequest request, HttpServletResponse response , ContactRecordQuery contactRecordQuery) throws IOException {
		Page page = searchProjectService.findContactRecordPage(contactRecordQuery);
		
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/cv/cvContactRecordList");
		//System.out.println("数量："+page.getTotalCount());
		//System.out.println(page.getResult());
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}

	public ModelAndView cvDetail(HttpServletRequest request, HttpServletResponse response ) throws IOException {
		
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/cv/cvDetail");		
		mv.addObject("id", request.getParameter("id"));
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}

}
